<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        #main {
            width: 700px;
            height: 500px;
        }
    </style>
</head>
<body>

<div id="main"></div>

<script src="http://lib.baomitu.com/echarts/4.7.0/echarts.min.js">

</script>

<script>
    const dom = document.getElementById('main')
    const myChart = echarts.init(dom)

    const option = {
        xAxis: {
            name: '语言',
            data: ['java', 'go', 'js']
        },
        yAxis: {
            name: '人数',
            splitNumber: 10, //分割段数
        },
        series: [
            {
                name: '学习人数',
                type: 'bar',
                data: [30, 20, 40]
            },
            {
                name: '就业人数',
                type: 'bar',
                data: [60, 40, 20]
            }
        ],
        title: {
            text: '前端学习语言人数',
            subtext: '前端常用语言学习人数',
            left: 'center',
            textStyle: {
                color: 'maroon',
                fontSize: 24
            },
            subtextStyle: {
                color: 'orange',
                fontSize: 16
            },
        },
        tooltip: {
            trigger: 'item',
            // trigger: 'axis',
        },
        // 绘图区 left right bottom right 绘图区在容器内的边距
        grid: {
            top: 80
        },
        //控制那个显示
        legend: {
            data: ['学习人数', '就业人数'],
            left: 'left',
        },
        //工具栏
        toolbox: {
            feature: {
                saveAsImage: {},
                dataView: {}, //编辑数据
                restore: {},
                dataZoom: {}, //放大缩小
                magicType: {
                    type: ['line', 'stack'] //切换图表
                },

            },
            left: 'right',
        }
    }

    myChart.setOption(option)
</script>
</body>
</html>
